<!--
 * @Author: your name
 * @Date: 2021-08-25 10:19:15
 * @LastEditTime: 2021-08-25 18:55:45
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \briup\5-javascript\day03\2-对象的删除.html
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        var person = {
            name: 'zs',
            age: 100,
            products: {
                name: '笔记本',
                price: 200.2
            },
            plus: function() {
                console.log('plus');
            }
        }

        // for (var key in person) {
        //     if (typeof person[key] == 'object') {
        //         for (var index in person[key]) {
        //             delete person[key][index];
        //         }
        //         console.log(person[key]); //{}
        //         person[key] = null;
        //     }
        //     delete person[key];

        // }
        // console.log(person);//{}
        // person = null;//赋予它空指针



        //delete person.age; //删除的是age的值
        //console.log(person.age); //undefined

        // delete person.products.name;//删除products里面的name
        // delete person.products.price;//删除products里面的price

        // console.log(person.products);//删除name、price，还剩下{},所以结果为{}
        // products = null;

        // console.log(person);

        //delete person.products; //删除products里所有东西
        //console.log(person.products); //删除{
        //         name: '笔记本',
        //         price: 200.2
        //     },结果为underfined
        //console.log(person);

        // delete person.plus;
        // console.log(person);
    </script>
</head>

<body>

</body>

</html>